package com.shj.em.biz.prod.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.shj.em.biz.prod.entity.MachineEffort;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 订单工时表 Mapper 接口
 * </p>
 *
 * @author Shen Huang Jian
 * @since 2018-11-27
 */
@Mapper
public interface MachineEffortMapper extends BaseMapper<MachineEffort> {
    /**
     * 分页查询
     * @param page 分页信息
     * @return
     */
    List<MachineEffort> queryMachineEffortPage(Page<MachineEffort> page, Map<String, Object> params);

    List<MachineEffort> findMachineEffortByProgramId(Map<String, Object> params);

    BigDecimal queryFinishedNumOfProgram(Map<String, Object> params);

    List<MachineEffort> findByDate(@Param("workDate") Date workDate);

    /**
     * 获取工单是否有跨班情况
     * @param params
     * @return
     */
    MachineEffort previousUnFinished(Map<String, Object> params);

    List<MachineEffort> findWeekEffort(@Param("weekFrom") Date weekFrom, @Param("weekTo") Date weekTo);

    List<MachineEffort> findWorkDaysInWeek(@Param("weekFrom") Date weekFrom, @Param("weekTo") Date weekTo);

    /**
     * 获取当天每台机器理论时间和实际加工时间
     * @param workDate
     * @return
     */
    List<MachineEffort> findOneDayMachineEffort(@Param("workDate") Date workDate);

    List<MachineEffort> findRangeMachineEffort(@Param("from") Date from, @Param("to") Date to);

    /**
     * 获取机器使用的天数
     * @param from
     * @param to
     * @return
     */
    List<MachineEffort> findMachineUsageDays(@Param("from") Date from, @Param("to") Date to);

}
